import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/
export const constantRouterMap = [
  {path: '/login', component: () => import('@/views/login/index'), hidden: true},
  {path: '/404', component: () => import('@/views/404'), hidden: true},
  {
    path: '',
    component: Layout,
    redirect: '/home',
    children: [{
      path: 'home',
      name: 'home',
      component: () => import('@/views/home/index'),
      meta: {title: '首页', icon: 'home'}
    }]
  }
]

export const asyncRouterMap = [


  {
    path: '/system',
    component: Layout,
    redirect: '/system/usernamage',
    name: 'system',
    meta: {title: '系统管理', icon: '系统管理'},
    alwaysShow: true,
    children: [
      {
        path: 'usernamage',
        name: 'user',
        component: () => import('@/views/system/usernamage/index'),
        meta: {title: '用户管理', icon: '用户管理'}
      },
      {
        path: 'rolemanage',
        name: 'role',
        component: () => import('@/views/system/rolemanage/index'),
        meta: {title: '角色管理', icon: '角色管理'}
      },
      {
        path: 'menumanage',
        name: 'menu',
        component: () => import('@/views/system/menumanage/index'),
        meta: {title: '菜单管理', icon: '菜单管理'}
      },{
        path: 'roledis',
        name: 'roleDistribute',
        component: () => import('@/views/system/roledis/index'),
        meta: {title: '角色分配', icon: '角色分配'}
      },{
        path: 'roleau',
        name: 'roleAuth',
        component: () => import('@/views/system/roleau/index'),
        meta: {title: '角色授权', icon: '角色授权管理'}
      },{
        path: 'allocMenu',
        name: 'allocMenu',
        component: () => import('@/views/system/rolemanage/allocMenu'),
        meta: {title: '分配菜单'},
        hidden:true
      },{
        path: 'allocResource',
        name: 'allocResource',
        component: () => import('@/views/system/rolemanage/allocResource'),
        meta: {title: '分配资源'},
        hidden:true
      },{
        path: 'addMenu',
        name: 'addMenu',
        component: () => import('@/views/system/menumanage/add'),
        meta: {title: '添加菜单'},
        hidden: true
      },{
        path: 'updateMenu',
        name: 'updateMenu',
        component: () => import('@/views/system/menumanage/update'),
        meta: {title: '更新菜单'},
        hidden: true
      },
      {
        path: 'resource',
        name: 'resource',
        component: () => import('@/views/system/resource/index'),
        meta: {title: '资源管理', icon: 'ums-resource'}
      },
      {
        path: 'resourceCategory',
        name: 'resourceCategory',
        component: () => import('@/views/system/resource/categoryList'),
        meta: {title: '资源分类'},
        hidden: true
      },

    ]
  },
  {
    path: '/pms',
    component: Layout,
    redirect: '/pms/product',
    name: 'pms',
    meta: {title: '商品管理', icon: 'product'},
    alwaysShow: true,
    children: [
      {
        path: 'product',
        name: 'product',
        component: () => import('@/views/pms/product/index'),
        meta: {title: '门店管理', icon: 'product-list'}
      },
      {
        path: 'addProduct',
        name: 'addProduct',
        component: () => import('@/views/pms/product/add'),
        meta: {title: '商品类别', icon: 'product-add'}
      },
      {
        path: 'productCate',
        name: 'productCate',
        component: () => import('@/views/pms/productCate/index'),
        meta: {title: '品牌管理', icon: 'product-cate'}
      },
      {
        path: 'ShopList',
        name: 'ShopList',
        component: () => import('@/views/pms/productCate/ShopList'),
        meta: {title: '商品列表', icon: 'product-cate'}
      },
      {
        path: 'Demo',
        name: 'Demo',
        component: () => import('@/views/pms/productCate/Demo'),
        meta: {title: '老曹模块', icon: 'product-cate'}
      },
      {
        path: 'changku',
        name: 'changku',
        component: () => import('@/views/pms/productCate/changku'),
        meta: {title: '仓库管理', icon: 'product-cate'}
      }
    ]
  },

  {path: '*', redirect: '/404', hidden: true}
]

export default new Router({
  mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})

